import os

extensions = ['.cpp', '.h', '.qml', '.hpp', '.c', '.ui']  # Qt常见扩展名
exclude_dirs = ['build', 'release', '.git']  # 排除目录

total_lines = 0
for root, dirs, files in os.walk('.'):
    dirs[:] = [d for d in dirs if d not in exclude_dirs]  # 跳过排除目录
    for file in files:
        if any(file.endswith(ext) for ext in extensions):
            path = os.path.join(root, file)
            try:
                with open(path, 'r', encoding='utf-8') as f:
                    total_lines += len(f.readlines())
            except UnicodeDecodeError:
                print(f"跳过非文本文件: {path}")

print(f"总代码行数: {total_lines}")